/*
 ============================================================================
 Name		: TradeBlockQueryFunds.h
 Author	  : spring xu
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CTradeBlockQueryFunds declaration
 ============================================================================
 */

#ifndef TRADEFUNDQUERYHISTORY_H
#define TRADEFUNDQUERYHISTORY_H

// INCLUDES
#include "TradeBlock.h"
#include "Control.h"
#include "TableWidget.h"
#include "TradeBlockNetwork.h"

// CLASS DECLARATION

class CTradeFundQueryHistory: public CTradeBlock, public MWidgetObserver, public MPushButtonObserver//,public MReqObserver
{
public:
    ~CTradeFundQueryHistory();

    static CTradeFundQueryHistory* NewL(CBaseBlock* bsBack);

    static CTradeFundQueryHistory* NewLC(CBaseBlock* bsBack);
public:
	enum TQueryType
	{
		EQueryType_Entrust,
		EQueryType_Turnover,
	};
	
	enum TQueryStatus
	{
		EQueryStatus_Query,
		EQueryStatus_Result,
	};
	
private:
    CTradeFundQueryHistory(CBaseBlock* bsBack);

    void ConstructL();

public:
    void OnDraw(CFbsBitGc& g) const;

    void OnKeyDown(TInt keyCode);
    
    void OnMouseDown(const TPoint& aPt);
    
    void OnMouseMove(const TPoint& aPt);

    void OnMouseUp(const TPoint& aPt);

    void SizeChanged();    
    
    void ChangeFocus(TBool aFoucs, const TInt& keyCode);
    
	void OnInput(const TDesC8& strInput);
	
protected:
    void AddTabs();
    
private:
    void CreateTable();
	void InitNetworkData();
	
public:
    // from MWidgetObserver
    void UpdateScreen();
    
    void SelectOneRow(TInt aRowIndex);
    
    void LoseFocus(const TInt& keycode);
    
public:// MPushButtonObserve
    void PushButtonClicked();
    
public:
	TBool ProcessTradeNetworkMsg(TInt nError, TAny* p, const TDesC8& aBodyData);
	//TBool UpdateTradeNetwork(TInt nProgress);
	
private:
	void CreateControls();
    void LayoutControls();
    void ResetControlDate();
    
    TBool AppendNetworkData(p_ofOrder_info_t p_ofOrdersArray);
	TBool AppendNetworkData(p_ofOrder_confirm_info_t p_confirmofOrdersArray);
    
private:
	enum TControlType
	{
		EControlType_SelectBox,
		EControlType_BegineDate,
		EControlType_EndDate,
		EControlType_ButtonConfirm,
		EControlType_ButonReset,
		EControlTypeCount
	};
	enum TQuerySelectType
	{
		EQuerySelectType_Turnover,
		EQuerySelectType_Entrust,
	};
	enum TNetworkStatus
	{
		ENetworkStatus_None,	
		ENetworkStatus_Req,
		ENetworkStatus_Resp
	};
private:
    CTableWidget* iTable;
    
    TInt iQueryType;
    TInt iQueryStatus;

	CLabelSelectBox*	iSelectBoxType;
    CSingleLineTextInput* 	iBeginDate;
    CSingleLineTextInput*	iEndDate;
    CPushButton*		iButtonConfirm;
    CPushButton*		iButtonReset;
    
    CPushButton*		iButtonMore;
    
    CControl*	iControls[EControlTypeCount];
    TInt iFocusControl;
    
    TInt	iNetworkStatus;
    TInt	iNumberOfElement;
    TBool	iCanReq;
};

#endif // TRADEBLOCKQUERYHISTORYDELIVERY_H
